<template>
  <div class="app-container" v-loading="loading.getPageList">
    <div>
      <el-button type="primary" size="small" @click="save">保存</el-button>
      <el-button type="primary" size="small" @click="getConfigs()">
        刷新
      </el-button>
    </div>
    <br />
    <editPanel ref="editPanel"></editPanel>
  </div>
</template>

<script>
import TableIndex from "@/layout/mixin/TableIndex";
import editPanel from "./components/editPanel";
export default {
  components: {
    editPanel,
  },
  mixins: [TableIndex],
  data() {
    return {
      moduleName: "dynamicFormDesign",
      form: {},
    };
  },
  computed: {},
  mounted() {
    this.getConfigs();
  },
  methods: {

    save() {
      this.loading.getPageList = true;
      this.$store
        .dispatch("plugin/addOrUpdateConfig",this.$refs.editPanel.getControls())
        .then((res) => {
          this.loading.getPageList = false;
          this.getConfigs();
        })
        .catch((e) => {
          this.loading.getPageList = false;
        });
    },
    getConfigs() {
      this.loading.getPageList = true;
      this.$store
        .dispatch("plugin/getPluginApplyConfigs")
        .then((res) => {
          this.loading.getPageList = false;
          if (res && res.configs) {
            this.$nextTick(() => {
              this.$refs.editPanel.setControls(res);
            });
          }
        })
        .catch((e) => {
          this.loading.getPageList = false;
        });
    },
    getPageList() {},
  },
};
</script>

<style lang="scss"></style>
